package cn.topiam.employee.common.entity.app;

import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import cn.topiam.employee.common.enums.app.AppProtocol;
import cn.topiam.employee.common.enums.app.AppType;
import cn.topiam.employee.common.enums.app.AuthorizationType;
import cn.topiam.employee.common.enums.app.InitLoginType;
import cn.topiam.employee.support.repository.domain.LogicDeleteEntity;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;

import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET;
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_WHERE;

/**
 * 应用
 *
 * @author TopIAM
 * Created by support@topiam.cn on  2021/9/11 21:07
 */
@Getter
@Setter
@ToString
@Entity
@Accessors(chain = true)
@Table(name = "app")
@SQLDelete(sql = "update app set " + SOFT_DELETE_SET + " where id_ = ?")
@Where(clause = SOFT_DELETE_WHERE)
public class AppEntity extends LogicDeleteEntity<Long> {

    /**
     * 应用名称
     */
    @Column(name = "name_")
    private String name;

    /**
     * 唯一CODE 不可修改
     */
    @Column(name = "code_")
    private String code;

    /**
     * 客户端ID
     */
    @Column(name = "client_id")
    private String clientId;
    /**
     * 客户端秘钥
     */
    @Column(name = "client_secret")
    private String clientSecret;

    /**
     * 模板
     */
    @Column(name = "template_")
    private String template;

    /**
     * 协议
     */
    @Column(name = "protocol_")
    private AppProtocol protocol;

    /**
     * 应用类型
     */
    @Column(name = "type_")
    private AppType type;

    /**
     * 应用图标
     */
    @Column(name = "icon_")
    private String icon;

    /**
     * SSO 发起登录类型
     */
    @Column(name = "init_login_type")
    private InitLoginType initLoginType;

    /**
     * SSO 发起登录URL
     */
    @Column(name = "init_login_url")
    private String initLoginUrl;

    /**
     * SSO 授权类型
     */
    @Column(name = "authorization_type")
    private AuthorizationType authorizationType;

    /**
     * 是否启用
     */
    @Column(name = "is_enabled")
    private Boolean enabled;
}
